var express = require('express');
const { get, Delete,getOne,change } = require("../api/adminsData")
var router = express.Router();
require("lodash");


router.get('/', async function (req, res, next) {
  const { curPage, eachPage } = req.query;
  const data = await get({ curPage, eachPage })
  res.send(data);

});

// 删除
router.delete("/",async function (req, res, next) {
  const{_id} =req.body;
  const data=await Delete(_id);
  res.send(data)
});

// 修改
router.patch('/change', async function (req, res, _next) {
  // 请求体获取到到参数
  const { adminName, adminPassword,phone , _id} = req.body;
  const data = await change({adminName, adminPassword,phone , _id})
  console.log(data,222222222);
  res.send(data);
})
// 获取_id对应数据
router.get('/getone', async function (req, res, _next) {
  const { _id } = req.query;
  const data = await getOne({_id})
  res.send(data);

})

//暴露接口
module.exports = router;
